import request from '@/config/axios'

const baseURL = '/system/poster'

export interface Poster {
  posterUrl: string
  posterType: number
  qrCodeWidth?: number //二维码宽
  qrCodeHeight?: number // 二维码高
  qrCodePositionTop?: number //上边距
  qrCodePositionRight?: number //右边距
  qrCodePositionBottom?: number //下边距
  qrCodePositionLeft?: number //左边距
  ifSwitch?: number //是否开启
}

export interface GetPoster extends PageParam {
  posterType?: number
}

// 创建海报
export const createPoster = async (data: Poster) => {
  return await request.post<boolean>({ url: `${baseURL}/create`, data })
}

// 更新海报
export const updatePoster = async (data: Poster & { id: string }) => {
  return await request.post<boolean>({ url: `${baseURL}/update`, data })
}

// 删除海报
export const deletePoster = (id: string) =>
  request.delete<boolean>({ url: `${baseURL}/delete`, params: { id } })

//   分页获取海报列表
export const getPagePoster = async (data: GetPoster) => {
  return await request.post<PageResult<Poster & { id: string }>>({
    url: `${baseURL}/page-poster`,
    data
  })
}

// 获取海报详情
export const getDetailPoster = async (id: string) => {
  return await request.get<Poster & { id: string }>({
    url: `${baseURL}/get-poster-detail`,
    params: { id }
  })
}
